# 1.2 𝒏次插值的Lagrange形式

n = 5
x = [0.4, 0.55, 0.65, 0.8, 0.9]
y = [0.41075, 0.57815, 0.69675, 0.88811, 1.02652]
xx = 0.6
yy = 0
for i in range(n):
    t = 1
    for k in range(n):
        if (k == i):
            continue
        t *= (xx - x[k]) / (x[i] - x[k])
    yy += t * y[i]

print("y_predict= %.4f" % yy)
